package com.module.check.manager;

import org.hibernate.Session;

import base.dao.GenericHibernateDao;
import base.manager.GenericHibernateManager;
import base.util.Page;

import com.module.check.dao.TestimonyTaskDao;
import com.module.check.vo.TestimonyTask;

public class TestimonyTaskManager extends GenericHibernateManager<TestimonyTask, Long> {
	private TestimonyTaskManager(){}
	
	private static TestimonyTaskManager manager;
	
	public synchronized static TestimonyTaskManager getInstance(){
		if(manager == null)
			manager = new TestimonyTaskManager();
		return manager;
	}
	
	private TestimonyTaskDao dao = TestimonyTaskDao.getInstance();
	
	/**
	 * 查询稽查任务列表
	 * @param pageObj
	 * @param pu
	 * @return
	 * @throws Exception
	 */
	public Page list(Page pageObj,TestimonyTask pu) throws Exception{
		Session session = this.getSession();
		Page page = new Page();
		try {
			page = dao.getList(session,pu, pageObj.getStart(),pageObj.getLimit());
		} catch (Exception e) {
			throw e;
		} finally {
			this.closeSession();
		}
		return page;
	}
	/**
	 * 返回附件下载地址
	 * @param testimonyId
	 * @return
	 * @throws Exception
	 */
	public String getFileUrl(Long testimonyId) throws Exception{
		Session session = this.getSession();
		String url = "";
		try{
			url = dao.getFileUrl(session, testimonyId);
		}catch(Exception e){
			throw e;
		}finally {
			this.closeSession();
		}
		return url;
	}
	@Override
	public GenericHibernateDao<TestimonyTask, Long> getDao() {
		// TODO Auto-generated method stub
		return null;
	}
}
